/* Import modern font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* CSS Variables - Premium Color Palette */
:root {
    /* Primary Colors */
    --primary-gradient-start: hsl(260, 70%, 55%);
    --primary-gradient-end: hsl(220, 85%, 60%);
    --accent-purple: hsl(280, 80%, 65%);
    --accent-blue: hsl(200, 90%, 55%);

    /* Background Colors */
    --bg-dark: hsl(230, 20%, 10%);
    --bg-panel: hsla(230, 20%, 15%, 0.7);
    --bg-input: hsla(230, 15%, 20%, 0.5);

    /* Text Colors */
    --text-primary: hsl(0, 0%, 95%);
    --text-secondary: hsl(0, 0%, 70%);
    --text-muted: hsl(0, 0%, 50%);

    /* UI Elements */
    --border-color: hsla(220, 50%, 50%, 0.3);
    --shadow-glow: hsla(260, 70%, 55%, 0.3);
    --success-green: hsl(145, 65%, 55%);
    --error-red: hsl(0, 70%, 60%);

    /* Spacing */
    --gap-sm: 0.5rem;
    --gap-md: 1rem;
    --gap-lg: 1.5rem;
    --gap-xl: 2rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* Global Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, hsl(230, 25%, 8%) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 20% 50%, hsla(260, 70%, 55%, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, hsla(220, 85%, 60%, 0.1) 0%, transparent 50%);
    z-index: -1;
    animation: bgPulse 10s ease-in-out infinite alternate;
}

@keyframes bgPulse {
    0% {
        opacity: 0.3;
    }

    100% {
        opacity: 0.6;
    }
}

/* Container */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: var(--gap-lg);
    gap: var(--gap-lg);
}

/* Header */
.header {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--gap-lg) var(--gap-xl);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header h1 span {
    background: linear-gradient(135deg, var(--primary-gradient-start), var(--primary-gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    color: var(--text-secondary);
    margin-top: var(--gap-sm);
    font-size: 0.95rem;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: var(--gap-lg);
    flex: 1;
    min-height: 0;
}

/* Control Panel */
.control-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--gap-lg);
    display: flex;
    flex-direction: column;
    gap: var(--gap-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
}

.control-panel h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--gap-sm);
}

/* Input Format Info */
.input-info {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--gap-md);
    margin-bottom: var(--gap-sm);
}

.input-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--gap-sm);
}

.input-info code {
    display: block;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    padding: var(--gap-sm);
    font-size: 0.75rem;
    color: var(--accent-blue);
    font-family: 'Courier New', monospace;
    overflow-x: auto;
    white-space: nowrap;
}

/* Textarea */
#inputTextArea {
    width: 100%;
    min-height: 200px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--gap-md);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    resize: vertical;
    transition: all 0.3s ease;
}

#inputTextArea:focus {
    outline: none;
    border-color: var(--primary-gradient-end);
    box-shadow: 0 0 0 3px var(--shadow-glow);
}

#inputTextArea::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.button-group {
    display: flex;
    gap: var(--gap-md);
}

button {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-gradient-start), var(--primary-gradient-end));
    color: white;
    box-shadow: 0 4px 15px var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-dark);
    border-color: var(--accent-purple);
}

/* Message Box */
.message-box {
    padding: var(--gap-md);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    display: none;
    animation: slideIn 0.3s ease;
}

.message-box.show {
    display: block;
}

.message-box.error {
    background: hsla(0, 70%, 60%, 0.1);
    border: 1px solid var(--error-red);
    color: var(--error-red);
}

.message-box.success {
    background: hsla(145, 65%, 55%, 0.1);
    border: 1px solid var(--success-green);
    color: var(--success-green);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stats */
.stats {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--gap-md);
    margin-top: auto;
}

.stats h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: var(--gap-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--gap-sm) 0;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stat-value {
    color: var(--accent-blue);
    font-weight: 600;
    font-size: 1.1rem;
}

/* Map Container */
.map-container {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    min-height: 500px;
}

/* Leaflet Customization */
.leaflet-container {
    background: hsl(230, 20%, 12%);
    font-family: 'Inter', sans-serif;
}

.leaflet-popup-content-wrapper {
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(20px);
}

.leaflet-popup-tip {
    background: var(--bg-panel);
}

.leaflet-popup-content {
    margin: var(--gap-md);
    font-size: 0.9rem;
}

.leaflet-popup-content h4 {
    color: var(--accent-blue);
    margin-bottom: var(--gap-sm);
    font-size: 1rem;
}

/* Custom marker styles */
.custom-marker {
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .control-panel {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: var(--gap-md);
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .button-group {
        flex-direction: column;
    }
}

/* Loading State */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-gradient-end);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}